<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Http\JsonResponse;
use Illuminate\Routing\Controller as BaseController;
use stdClass;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

    /**
     * @param $data
     * @return JsonResponse
     */
    public function OkJson($data): JsonResponse
    {
        return response()->json([
            'code' => 200,
            'msg'  => 'ok',
            'data' => $data
        ]);

    }

    /**
     * @param int $code
     * @param string $msg
     * @return JsonResponse
     */
    public function ErrJson(string $msg, int $code = 1001): JsonResponse
    {
        return response()->json([
            'code' => $code,
            'msg'  => $msg,
            'data' => new stdClass()
        ]);
    }
}
